package com.bocai.dahuatech.ui.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;

import com.bocai.dahuatech.R;
import com.bumptech.glide.Glide;

public class ProductSizePicAdapter extends BaseAdapter{
    Context context;
    String[] pics;
    public ProductSizePicAdapter(Context context,String[] pics)
    {
        this.context=context;
        this.pics=pics;
    }
    @Override
    public int getCount() {
        return pics.length;
    }

    @Override
    public Object getItem(int position) {
        return pics[position];
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        ViewHolder viewHolder;
        if(convertView==null){
            viewHolder=new ViewHolder();
            convertView= LayoutInflater.from(context).inflate(R.layout.productsizepic_item,null);
            viewHolder.ivPic= (ImageView) convertView.findViewById(R.id.iv_productsizepic_item);
            convertView.setTag(viewHolder);
        }else{
            viewHolder= (ViewHolder) convertView.getTag();
        }
        Glide.with(context).load(pics[position]).into(viewHolder.ivPic);
        return convertView;
    }
    class ViewHolder{
        ImageView ivPic;
    }
}
